import mysql.connector
from config import MYSQL_CONFIG

def check_persons_data():
    conn = None
    cursor = None
    try:
        conn = mysql.connector.connect(**MYSQL_CONFIG)
        cursor = conn.cursor(dictionary=True)
        cursor.execute("SELECT rybh as id, jsh as room_number, xm as name, jjsrq as join_date, FXDJ, BHLX FROM persons WHERE jsh='106'")
        persons_data = cursor.fetchall()
        
        print("Persons data for room 106:")
        for person in persons_data:
            print(person)
        
        return persons_data
    except mysql.connector.Error as db_err:
        print(f"数据库错误: {str(db_err)}")
        return None
    except Exception as e:
        print(f"数据获取异常: {str(e)}")
        return None
    finally:
        if cursor: cursor.close()
        if conn and conn.is_connected(): conn.close()

if __name__ == "__main__":
    check_persons_data()